angular.module('starter', ['ionic', 'starter.controllers', 'starter.services','ngCordova'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    //姝ｅ紡鐜
    AV.initialize('8c4dst8wuiimm9nxj8puwrqrhmkxegkl2ittuy6a2jkmx1pl', '6lqn0keuf89uzoj8px4t47u9e39eimx7jo7ad1qy9pd125nm');
    //娴嬭瘯鐜
    //AV.initialize('64yipwcn159l9ehdf3j3x3xz1f1ly9r89x9gf7i2d1282dvz', 'w3xp0oibbzhweamm76ogo6r5dyzt82tczw7lssfvyj6hlarv');
    if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if (window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})

.config(function($stateProvider, $urlRouterProvider,$ionicConfigProvider) {

        $ionicConfigProvider.platform.android.tabs.position('bottom');
  $stateProvider

      .state('tab', {
        url: '/tab',
        abstract: true,
        templateUrl: 'templates/tabs.html',
        controller: 'AppCtrl'
      })

  .state('tab.take', {
    url: '/take',
    views: {
      'tab-take': {
        templateUrl: 'templates/tab-take.html',
        controller: 'TakeCtrl'
      }
    }
  })

  /*.state('tab.tasks', {
      url: '/tasks',
      views: {
        'tab-tasks': {
          templateUrl: 'templates/tasks/missions.html',
          controller: 'MissionsCtrl'
        }
      }
    })
    .state('tab.task-detail', {
      url: '/task/:taskId',
      views: {
        'tab-task-detail': {
          templateUrl: 'templates/task-detail.html',
          controller: 'TaskDetailCtrl'
        }
      }
    })*/
      /*.state('tab.sell', {
        url: '/sell',
        views: {
          'tab-sell': {
            templateUrl: 'templates/tab-sell.html',
            controller: 'SellCtrl'
          }
        }
      })*/
  .state('tab.setting', {
    url: '/setting',
    views: {
      'tab-setting': {
        templateUrl: 'templates/tab-setting.html',
        controller:'AccountCtrl' //'AccountCtrl' //
      }
    }
  })
  /**
   * 璁剧疆--鍒嗕韩浜岀淮鐮?
   */
      .state('tab.QRcode',{
          url:'/setting/QRcode',
          views: {
              'tab-setting': {
                  templateUrl: 'templates/qrcode.html'
              }
          }
      })
  /**
   * 鍩烘湰淇℃伅
   */
      .state('tab.baseinfo', {
        url: '/account/baseinfo',
        cached:false,
        views: {
          'tab-setting': {
            templateUrl: 'templates/account/baseinfo.html',
            controller: 'AccountInfoCtrl'
          }
        }
      })
  /**
   * 淇敼瀵嗙爜
   */
      .state('tab.password', {
        url: '/account/password',
        cached:false,
        views: {
          'tab-setting': {
            templateUrl: 'templates/account/password.html',
            controller: 'PasswordCtrl'
          }
        }
      })
      //宸插畬鎴愯鍗?
      .state('tab.finish', {
        url: '/account/finish',
        cached:false,
        views: {
          'tab-setting': {
            templateUrl: 'templates/account/finish.html',
            controller: 'AccountInfoCtrl'
          }
        }
      })
      //鍒嗗尯鏂拌鍗?
      .state('tab.neworder', {
          url: '/account/neworder',
          cached:false,
          views: {
              'tab-setting': {
                  templateUrl: 'templates/account/neworder.html',
                  controller: 'AccountInfoCtrl'
              }
          }
      })

  /**
   *钀ラ攢
   * @author Nico
   */
      .state('tab.goodsType', {
        url: '/markettype',
        views: {
          'tab-sell': {
            templateUrl: 'templates/sells/markettype.html',
            controller: 'GoodsType'
          }
        }
      })
      .state('tab.goodslist', {
        url: '/marketgoods/:search/:type',
        cached:false,
        views: {
          'tab-sell': {
            templateUrl: 'templates/sells/marketgoods.html',
            controller: 'GoodsListCtrl'
          }
        }
      })
      .state('tab.marketOrders', {
        url: '/marketOrders',
        views: {
          'tab-sell': {
            templateUrl: 'templates/sells/marketOrders.html',
            controller: 'MarketOrderCtrl'
          }
        }
      })
  /**
   * 浠诲姟
   */
      .state('tab.tasks', {
          url: '/tasks',
          cashed:false,
          views: {
              'tab-tasks': {
                  templateUrl: 'templates/mission/missions.html',
                  controller: 'MissionsCtrl'
              }
          }
      })
      .state('tab.missions', {
          url: '/missions',
          cashed:false,
          views: {
              'tab-tasks': {
                  templateUrl: 'templates/mission/missions.html',
                  controller: 'MissionsCtrl'
              }
          }
      })
      .state('tab.mymission', {
          url: '/mymission/:status/:type/:orderid/:title',
          cashed:false,
          views: {
              'tab-tasks': {
                  templateUrl: 'templates/mission/mymission.html',
                  controller: 'MyMissionCtrl'
              }
          }
      })
      .state('tab.missionDetail', {
          url: '/missionDetail/:orderid',
          cashed:false,
          views: {
              'tab-tasks': {
                  templateUrl: 'templates/mission/missionDetail.html',
                  controller: 'MissionDetailCtrl'
              }
          }
      })
      .state('tab.completMission', {
          url: '/completMission/:orderid/:payway/:finalAmount',
          cashed:false,
          views: {
              'tab-tasks': {
                  templateUrl: 'templates/mission/completMission.html',
                  controller: 'CompletMissionCtrl'
              }
          }
      })
      //閫?鎹㈣揣
      .state('tab.afterSales',{
          url:'/afterSales',
          cashed:false,
          views:{
              'tab-tasks':{
                  templateUrl:'templates/afterSales/afterSales.html',
                  controller:'AfterSalesCtr'
              }
          }
      })
      .state('tab.returnGoodsMission',{
          url:'/returnGoodsMission/:orderType/:title/:typeName',
          cashed:false,
          views:{
              'tab-tasks':{
                  templateUrl:'templates/afterSales/missionDetail.html',
                  controller:'returnGoodCtr'
              }
          }
      })
      .state('tab.exchangeGoodsMission',{
          url:'/exchangeGoodsMission/:orderType/:title/:typeName',
          cashed:false,
          views:{
              'tab-tasks':{
                  templateUrl:'templates/afterSales/missionDetail.html',
                  controller:'returnGoodCtr'
              }
          }
      })
  /**
   * 浠诲姟 鎵嬪姩鏌ヨ
   */
      .state('tab.searchMission', {
          url: '/mymission/:orderid',
          views: {
              cashed:false,
              'tab-tasks': {
                  templateUrl: 'templates/mission/search.html',
                  controller: 'SearchMissionCtrl'
              }
          }
      })


        $urlRouterProvider.otherwise('/tab/take');

});
var service = angular.module('starter.services', []);

var app = angular.module('starter.controllers', ['starter.services','starter.filter']);

